import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";

export default defineConfig(({ mode }) => {
  const config = loadEnv(mode, "./");
  console.log("-------------------------------");
  console.log(mode);
  console.log(config);
  console.log("-------------------------------");
  return {
    plugins: [react()],
    base: "./",
    build: {
      chunkSizeWarningLimit: Infinity,
    },
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "./src"),
        "~": path.resolve(__dirname, "./"),
      },
    },
    server: {
      open: false,
      port: 3000,
      proxy: {
        "^/api": {
          target: config.VITE_TARGET,
          changeOrigin: true,
          ws: true,
        },
      },
    },
  };
});
